/*
 * MenuPane.java
 *
 * Copyright 2011 Universidad Francisco de Paula Santander (UFPS).
 * Todos los Derechos Reservados.
 * Creado el 24/04/2011, 12:58:35 AM
 */
package com.ufps.cuatro.modelo.representacion;

import com.ufps.cuatro.util.base.ObjectBase;
import java.awt.BorderLayout;
import java.util.ArrayList;

/**
 * <i><b>MenuPane:</b></i><p>Representa un Menu.</p>
 * 
 * @author Carlos A. Torres C. - Dolly E. Guerrero. <https://code.google.com/p/tesis4dor/> 
 * @see ObjectBase
 */
public class MenuPane extends ObjectBase{
    private static final long serialVersionUID = -4751522865184130220L;
    
    public final static int TOOLBAR = 0;
    public final static int MENU = 1;    
    
    private String strTitle;
    private String strName;
    private int mode = MENU;
    private String orientation = BorderLayout.NORTH;
    private ArrayList<OptionMenuPane> objOptions;
    public static int idOption = 0;

    public MenuPane(String strTitle) {
        super(idOption++);
        this.strTitle = strTitle;
        strName = "_" + strTitle.replaceFirst(" ", "");
    }

    public int getMode() {
        return mode;
    }

    public void setMode(int mode) {
        this.mode = mode;
    }

    public ArrayList<OptionMenuPane> getObjOptions() {
        return objOptions;
    }

    public void setObjOptions(ArrayList<OptionMenuPane> objOptions) {
        this.objOptions = objOptions;
    }

    public String getOrientation() {
        return orientation;
    }

    public void setOrientation(String orientation) {
        this.orientation = orientation;
    }

    public String getStrName() {
        return strName;
    }

    public void setStrName(String strName) {
        this.strName = strName;
    }

    public String getStrTitle() {        
        return strTitle;
    }

    public void setStrTitle(String strTitle) {
        this.strTitle = strTitle;
        strName = "_" + strTitle.replaceFirst(" ", "");
    }

    @Override
    public String toString() {
        return "Menu:" + strTitle;
    } 
    
    @Override    
    public int compareTo(Object o) {        
        MenuPane obj = (MenuPane) o;
        if(this.id > obj.id) {
            return 1;
        }
        else if(this.id < obj.id) {
            return -1;
        }
        else {
            return 0;
        }
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof MenuPane){
            MenuPane objMenu = (MenuPane) obj;
            return strTitle.equals(objMenu.getStrTitle());
        }
        return super.equals(obj);
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 71 * hash + (this.strTitle != null ? this.strTitle.hashCode() : 0);
        hash = 71 * hash + (this.strName != null ? this.strName.hashCode() : 0);
        return hash;
    }   
}
